<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>学生信息管理</title>
    <!-- 若您需要使用Kendo UI Professional，请联系版权人获得合法的授权或许可。 -->
    <!-- Bootstrap css -->
    <link href="https://magicbox.bk.tencent.com/static_api/v3/assets/bootstrap-3.3.4/css/bootstrap.min.css" rel="stylesheet">
    <!-- kendo ui css -->
    <link href="https://magicbox.bk.tencent.com/static_api/v3/assets/kendoui-2015.2.624/styles/kendo.common.min.css" rel="stylesheet">
    <link href="https://magicbox.bk.tencent.com/static_api/v3/assets/kendoui-2015.2.624/styles/kendo.default.min.css" rel="stylesheet">
    <!-- font-awesome -->
    <link href="https://magicbox.bk.tencent.com/static_api/v3/assets/fontawesome/css/font-awesome.css" rel="stylesheet">
    <!--蓝鲸提供的公用样式库 -->
    <link href="https://magicbox.bk.tencent.com/static_api/v3/bk/css/bk.css" rel="stylesheet">
    <link href="https://magicbox.bk.tencent.com/static_api/v3/bk/css/bk_pack.css" rel="stylesheet">
    <link href="./static/css/jquery-confirm.min.css" rel="stylesheet" media="screen" />
    <!-- 如果要使用Bootstrap的js插件，必须先调入jQuery -->
    <script src="https://magicbox.bk.tencent.com/static_api/v3/assets/js/jquery-1.10.2.min.js"></script>
    <!-- 包括所有bootstrap的js插件或者可以根据需要使用的js插件调用　-->
    <script src="https://magicbox.bk.tencent.com/static_api/v3/assets/echarts-2.0/echarts-all.js"></script>
    <script src="https://magicbox.bk.tencent.com/static_api/v3/assets/bootstrap-3.3.4/js/bootstrap.min.js"></script>
    <script src="./static/js/jquery-confirm.min.js"></script>
    <!-- 包括所有kendoui的js插件或者可以根据需要使用的js插件调用　-->
    <script src="https://magicbox.bk.tencent.com/static_api/v3/assets/kendoui-2015.2.624/js/kendo.all.min.js"></script>
    <script src="https://magicbox.bk.tencent.com/static_api/v3/assets/echarts-2.0/echarts-all.js"></script>
    <script src="https://magicbox.bk.tencent.com/static_api/v3/bk/js/bk.js"></script>
</head>

<body class="bg-white" data-bg-color="bg-white">
    <div class="king-page-box">
        <div class="king-layout1-header">
            <nav>
                <div class="king-header2 navbar navbar-blue  f14">
                    <div class="nav-container">
                        <div class="navbar-header">
                            <button class="pull-right visible-xs navbar-toggle collapsed navbar-toggle-sm" type="button" data-toggle="collapse" data-target="#king-header2-navbar-collapse"> <i class="fa fa-fw fa-ellipsis-v">                    </i> </button>
                            <a class="navbar-brand">
                                <img src="./static/logo.jpg" alt="" class="logo" style="margin-top:-5px;"> </a>
                        </div>
                        <div class="navbar-collapse collapse" id="king-header2-navbar-collapse">
                            <ul class="nav navbar-nav navbar-left hidden-sm">
                                <li>
                                    <a>
                                        <span>SZIIT学生信息管理系统</span>
                                    </a>
                                </li>
                                <li  class="open">
                                    <a href="{{ url_for('allInfoPage') }}">
                                        <span>学生信息管理</span>
                                    </a>
                                </li>
                                <li>
                                    <a href="{{ url_for('showData') }}">
                                        <span>数据可视化</span>
                                    </a>
                                </li>
                            </ul>
                            <ul class="nav navbar-nav navbar-right">
                                {%  if session['user'] %}
                                    <li>
                                        <a>
                                            <span> {{ session['user'] }} </span>
                                        </a>
                                    </li>
                                    <li>
                                        <a href="{{ url_for('logout') }}">
                                            <span> 注销 </span>
                                        </a>
                                    </li>
                                {% else %}
                                    <li>
                                        <a href="{{ url_for('login') }}">
                                            <span> 登录 </span>
                                        </a>
                                    </li>
                                {% endif %}
                                {% if not session.get('admin') %}
                                <li>
                                    <a href="{{ url_for('admin') }}">
                                        <span> 管理员登录 </span>
                                    </a>
                                </li>
                                {% endif %}
                            </ul>
                        </div>
                    </div>
                </div>
            </nav>
             <div class="container-fluid mb0 ">
                 <div class="row">
                    <div class="col-md-1"></div>
                    <div class="col-md-10">
                        <div style="text-align:center">
                            <h1>学生信息管理</h1>
                        </div>
                        <section>
                             <div class="form-group clearfix">
                                 <div class="col-sm-offset-0 col-sm-12">
                                     <div class="bk-horizontal-line"></div>
                                 </div>
                             </div>
                         </section>
                        <div class="container-fluid mb0 ">
                            <form action="{{url_for('queryData')}}" method="post">
                                <div class="row">
                                    <div class="col-md-4">
                                        <div class="form-group f13">
                                            <label>姓名：</label>
                                            <input type="text" class="form-control" id="name" name="name">
                                        </div>
                                    </div>
                                    <div class="col-md-4">
                                        <div class="form-group ">
                                            <label>学院：</label>
                                            <input type="text" class="form-control" id="school" name="school">
                                        </div>
                                    </div>
                                    <div class="col-md-4">
                                        <div class="form-group f13">
                                            <label>班级：</label>
                                            <input type="text" class="form-control" id="classname" name="classname">
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-md-4">
                                        <div class="form-group f13">
                                            <label>电话：</label>
                                            <input type="text" class="form-control" id="phone" name="phone">
                                        </div>
                                    </div>
                                    <div class="col-md-4">
                                        <div class="form-group ">
                                            <label>用户名：</label>
                                            <input type="text" class="form-control" id="userInfo" name="userInfo">
                                        </div>
                                    </div>
                                    <div class="col-md-4"></div>
                                </div>
                                <div class="row">
                                    <section>
                                         <div class="form-group clearfix">
                                             <div class="col-sm-offset-0 col-sm-12">
                                                 <div class="bk-horizontal-line"></div>
                                             </div>
                                         </div>
                                    </section>
                                </div>
                                <div class="row">
                                    <div class="col-md-4"></div>
                                    <div class="col-md-4">
                                         <div class="form-group" style="text-align:center">
                                            <button type="submit" class="king-btn mr10  king-success">查询</button>
                                            <button type="button" class="king-btn king-default " onclick="resetFun()">重置</button>
                                        </div>
                                    </div>
                                    <div class="col-md-4"></div>
                                </div>
                            </form>
                            <div class="row">
                                <section>
                                     <div class="form-group clearfix">
                                         <div class="col-sm-offset-0 col-sm-12">
                                             <div class="bk-horizontal-line"></div>
                                         </div>
                                     </div>
                                </section>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-1"></div>
                </div>
                 <div class="row">
                    <div class="col-md-1"></div>
                    <div class="col-md-10">
                        <div style="text-align:center">
                            <table class="table table-striped table-bordered" id="tb-info">
                                <tr id="tb-title">
                                    <th style="text-align: center">姓名</th>
                                    <th style="text-align: center">学号</th>
                                    <th style="text-align: center">学院</th>
                                    <th style="text-align: center">班级</th>
                                    <th style="text-align: center">年龄</th>
                                    <th style="text-align: center">电话</th>
                                    <th style="text-align: center">email</th>
                                    <th style="text-align: center">用户名</th>
                                    <th style="text-align: center">修改</th>
                                    <th style="text-align: center">删除</th>
                                </tr>
                                {% for info in infos %}
                                    <tr id="tr-{{ info['用户名'] }}">
                                        {% for key, value in info.items() %}
                                            <td>{{ value }}</td>
                                        {% endfor %}
                                        <td>
                                            <a href="{{ url_for('editStudent') }}+{{ info['用户名'] }}+edit" class="edit-btn" onclick="return delAndEditFun(this)">
                                                <button type="button" class="btn btn-warning">修改</button>
                                            </a>
                                        </td>
                                        <td>
                                            <a href="{{ url_for('delStudent') }}+{{ info['用户名'] }}+del" class="edit-btn" onclick="return delAndEditFun(this)">
                                                <button type="submit" class="btn btn-danger">删除</button>
                                            </a>
                                        </td>
                                    </tr>
                                {% endfor %}
                            </table>
                        </div>
                    </div>
                    <div class="col-md-1"></div>
                </div>
            </div>
        </div>
    </div>

    <form action="" method="post" id="delAndEdit">
        <input id="delAndEdit-user" type="hidden" name="user" value="">
    </form>
</body>
<script type="text/javascript">

    function del (val) {
        var res = false;
        $.confirm({
            title: '确认',
            content: '确认要删除该数据吗?',
            type: 'green',
            icon: 'glyphicon glyphicon-question-sign',
            buttons: {
                ok: {
                    text: '确认',
                    btnClass: 'btn-primary',
                    action: function() {
                       val.submit()
                    }
                },
                cancel: {
                    text: '取消',
                    btnClass: 'btn-primary'
                }
            }
        });
        return res;
    }

    function delAndEditFun(val){
        var path = val.getAttribute("href").split("+");
        var address = path[0]
        var user = path[1]
        var operator = path[2]
        $('#delAndEdit').attr("action", address);
        $("#delAndEdit-user").attr("value", user);
        if (operator === "del"){
            $('#delAndEdit').attr("onsubmit", "return del(this)");
        }
        $('#delAndEdit').submit();
        return false;
    }

    function resetFun(){
       window.location.href = "{{ url_for('allInfoPage')}}"
    }
</script>
</html>